#include<bits/stdc++.h> 
using namespace std;
int n,l,r,ans;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	ans=r%n;
	r=r-ans;
	if(r-1>l)ans=n-1;
	cout<<ans;
	return 0;
}
